package com.hyacinth.serive;

import com.hyacinth.mapper.OrderMapper;
import com.hyacinth.model.OrderInfo;
import com.hyacinth.model.ProductInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class TestService {

    @Resource
    private OrderMapper orderMapper;

    @Resource
    private RestTemplate restTemplate;

    public OrderInfo selectOrderById(Integer orderId) {
        OrderInfo orderInfo = orderMapper.selectOrderById(orderId);
        String url = "http://product-service/product/" + orderInfo.getProductId();
        ProductInfo productInfo = restTemplate.getForObject(url, ProductInfo.class);
        orderInfo.setProductInfo(productInfo);
        return orderInfo;
    }

    public String selectOrderById2() {
        String url = "http://test-service/nacos/test2";
        String str = restTemplate.getForObject(url, String.class);
        return str;
    }
}
